package com.oig.sys.msg.dao;

import com.oig.sys.msg.entity.TbMqMsg;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
@author wuxl
*/
public interface ITbMqMsgDao extends JpaRepository<TbMqMsg, Integer>, JpaSpecificationExecutor<TbMqMsg> {

	@Query("from TbMqMsg m where m.id=:id")
	TbMqMsg getMqMsgById(@Param("id") Integer id);

	@Query("from TbMqMsg m where m.sendFlag is null  order by m.id asc")
	List<TbMqMsg> findUnReadyMsg();
	/**
	 * 没有发送并且正常的
	 */
	@Query("from TbMqMsg m where m.sendFlag='0' and m.errorFlag='0' order by m.id asc")
	List<TbMqMsg> findUnSendMsg();

}
